package com.xhx.stream.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.xhx.stream.dto.HumanDTO;
import com.xhx.stream.dto.VehicleDTO;
import com.xhx.stream.stream.CustomSendPublisher;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RequestMapping("/t")
@RestController
public class TestController {
	@Autowired
	private CustomSendPublisher sendPublisher;

	@GetMapping("/say")
	public String say(@RequestParam String content) {
		log.info("I receive {}", content);
		return "I know";
	}

	@GetMapping("/face/{msg}")
	public String sendFaceMsg(@PathVariable("msg") String msg) {
		sendPublisher.sendFaceMsg(msg);
		return "发送成功-Face";
	}

	@PostMapping("/human")
	public String sendHumanMsg(@RequestBody HumanDTO dto) {
		sendPublisher.sendHumanMsg(dto);
		return "发送成功-Human";
	}

	@PostMapping("/vehicle")
	public String sendVehicleMsg(@RequestBody VehicleDTO dto) {
		sendPublisher.sendVehicleMsg(dto);
		return "发送成功-Vehicle";
	}
	
}
